// 管理mock数据
const result = [
    {
        auditRegisterId: '1',
        teacherId: '100001',
        account: '100001',
        teacherName: '张三',
        result: 1
    },
    {
        auditRegisterId: '2',
        teacherId: '100002',
        account: '100002',
        teacherName: '张大三',
        result: 1
    },
    {
        auditRegisterId: '3',
        teacherId: '100003',
        account: '100003',
        teacherName: '张小三',
        result: 1
    },
    {
        auditRegisterId: '4',
        teacherId: '100004',
        account:'100004',
        teacherName: '张三三',
        result: 1
    },
    {
        auditRegisterId: '5',
        teacherId: '100005',
        account: '100005',
        teacherName: '张三四',
        result: 1
    },
    {
        auditRegisterId: '6',
        teacherId: '100006',
        account: '100006',
        teacherName: '张三六',
        result: 1
    },
    {
        auditRegisterId: '7',
        teacherId: '100007',
        account: '100007',
        teacherName: '张三七',
        result: 1
    },
    {
        auditRegisterId: '8',
        teacherId: '100008',
        account: '100008',
        teacherName: '张三为',
        result: 2
    },{
        auditRegisterId: '9',
        teacherId: '100009',
        account: '100009',
        teacherName: '张二三',
        result: 2
    },
    {
        auditRegisterId: '10',
        teacherId: '100010',
        account: '100010',
        teacherName: '张而三',
        result: 2
    },
    {
        auditRegisterId: '11',
        teacherId: '100011',
        account: '100011',
        teacherName: '张三来',
        result: 3
    },
    {
        auditRegisterId: '12',
        teacherId: '100012',
        account: '100012',
        teacherName: '张三啊',
        result: 3
    },
    {
        auditRegisterId: '13',
        teacherId: '100013',
        account: '100013',
        teacherName: '张三吖',
        result: 2
    },
    {
        auditRegisterId: '14',
        teacherId: '100014',
        account: '100014',
        teacherName: '张三说',
        result: 3
    },
    {
        auditRegisterId: '15',
        teacherId: '100015',
        account: '100015',
        teacherName: '张三嗄',
        result: 3
    },
    {
        auditRegisterId: '16',
        teacherId: '100016',
        account: '100016',
        teacherName: '张三就',
        result: 2
    },
    {
        auditRegisterId: '17',
        teacherId: '100017',
        account: '100017',
        teacherName: '张三发',
        result: 2
    },
    {
        auditRegisterId: '18',
        teacherId: '100018',
        account: '100018',
        teacherName: '张来三',
        result: 3
    },
    {
        auditRegisterId: '19',
        teacherId: '100019',
        account: '100019',
        teacherName: '张三分',
        result: 3
    },
    {
        auditRegisterId: '20',
        teacherId: '100020',
        account: '100020',
        teacherName: '张三可',
        result: 2
    },
]

export default {
    //返回的数据生成
    auditRegisterGet(options){ // 登录接口返回的数据
        //根据rows的不同，返回的数据数不同
        let len = parseInt(options.url.match(/rows=(\S*)&/)[1]);
        //console.log(len);
        return{
            code: 1,
            msg: "返回结果成功",
            data: {
                total: 100,
                auditRegisterInfo: result.slice(0,len)
            }
        }
    },
    auditRegisterOperate(options){
        let auditRegisterId = options.url.match(/auditRegisterId=(\S*)/)[1];
        let operateResult=parseInt(options.url.match(/result=(\S*)&/)[1]);
        for(let i of result){
            if(i.auditRegisterId===auditRegisterId){
                i.result=operateResult;
                break;
            }
        }
        return{
            code: 1,
            msg: "返回结果成功",
            data: {
            }
        }
    },
    auditRegisterBatchOperate(options){
        let str=options.body.split('&');
        let operationResult;
        let auditRegisterIds=[];
        for(let i of str){
            if(!i.includes('token')){
                if(i.includes('result')){
                    operationResult=parseInt(i.match(/result=(\S*)/)[1]);
                }else{
                    auditRegisterIds.push(i.match(/%5D=(\S*)/)[1]);
                }
            }
        }

        for(let i of auditRegisterIds){
            for(let j of result){
                if(j.auditRegisterId===i){
                    j.result=operationResult;
                    break;
                }
            }
        }
        return{
            code: 1,
            msg: "返回结果成功",
            data: {
            }
        }
    },
    getTeacherInfo:{
        code: 1,
        msg: "返回结果成功",
        data: {
            //随机生成数据
            teacherInfo:{
                account: /[0-9]{6,7}/,
                teacherId:'123',
                name:'@cname',
                password:/[0-9]{6,7}/,
                college:'计算科学与工程学院',
                e_mail:/[0-9]{6,7}@qq\.com/,
                phone: /[0-9]{9,10}/,
            }
        }
    },
}
